package com.itheima.user.feign;

import com.itheima.apis.user.IUserClient;
import com.itheima.model.common.dtos.ResponseResult;
import com.itheima.model.user.dtos.UserQueryDto;
import com.itheima.user.service.UserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@RestController
public class UserClient implements IUserClient {
    @Autowired
    private UserService userService;

    /**
     * 获取作者信息
     * @param authorId
     * @return
     */
    @Override
    @GetMapping("/api/v1/author/vo")
    public ResponseResult getAuthorVo(Integer authorId) {
        return userService.getAuthorVo(authorId);
    }

    /**
     * 分页查询用户列表（支持搜索）
     */
    @GetMapping("/api/v1/user/list")
    public ResponseResult listUsers(UserQueryDto dto) {
        return userService.listUsers(dto);
    }

    /**
     * 查询用户详情
     */
    @GetMapping("/api/v1/user/{id}")
    public ResponseResult getUserById(@PathVariable Integer id) {
        return userService.getUserById(id);
    }

    /**
     * 更新用户状态
     */
    @PutMapping("/api/v1/user/{id}/status")
    public ResponseResult updateUserStatus(@PathVariable Integer id,
                                          @RequestBody UserQueryDto dto) {
        return userService.updateUserStatus(id, dto);
    }
}
